<!--
 * @Author: tanlijun 2060803224@qq.com
 * @Date: 2022-11-15 19:36:27
 * @LastEditors: tanlijun 2060803224@qq.com
 * @LastEditTime: 2022-11-15 20:39:59
 * @FilePath: \js基础\js基础第二天\作业\拓展题.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>



  <script>
    let year = +prompt('请输入年份：')
    let mouth = +prompt('请输入月份：')
    let day = null
    // 给null是因为后面的值会有更改

    switch (mouth) {
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
        day = 31
        break
      case 4:
      case 6:
      case 9:
      case 11:
        day = 30
        break
      case 2:
        if (year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)) {
          day = 29
        } else {
          day = 28
        }
        break
    }
    alert(`${year}年的第${mouth}月有${day}天`)
  </script>
</body>

</html>